/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package etp.coofy.Commands;

import etp.USB.USBService;
import etp.coofy.Coofy;

/**
 *
 * @author mikulski
 */
public class USB_Status extends etp.USB.USBCommand implements etp.USB.InputCommand, etp.USB.OutputCommand {

    public static int COMMAND = 0x58;
    
    private Coofy surface;
    
    public USB_Status(Coofy surface) {
        this.surface = surface;
              
             
    }
    
    @Override
    public void receiveUSB(byte[] bytes) {
        int temp = (bytes[1] & 0xFF);
        int waterLevel = (bytes[3] & 0xFF);
        int error = (bytes[4] & 0xFF);
        int status = (bytes[5] & 0xFF);
        this.surface.LaTempValue.setText(Integer.toString(temp));
        this.surface.LaWlevelValue.setText(Integer.toString(waterLevel));
        this.surface.LaErrorValue.setText(Integer.toString(error));
        this.surface.LaInfoValue.setText(Integer.toString(status));
    }

    @Override
    public void sendCommand(USBService usbs) {
        this.defaultSendReceiveCommand(usbs, COMMAND, this, "Fehler bei der Statusabfrage");
    }

    @Override
    public void sendCommand(USBService usbs, byte[] bytes) {
        this.sendCommand(usbs);
    }
    
}
